package com.wlyuan.index.domain.index.repository.old;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 运单
 */
@Data
@Document(indexName = "transport_combine")
@EqualsAndHashCode(exclude = {
        "id",
        "waybillSize",
        "waybillType",
        "closeStatus",
        "totalWaybillQuantity",
        "feeGenerated",
        "carrierContactMobile",
        "carrierContactName",
})
@ToString
public class CombineIndexOld implements Serializable {
    @Data
    @EqualsAndHashCode(exclude = {"toContactName", "customerName"})
    @ToString
    public static class Waybill implements Serializable {
        @Id
        @Field(type = FieldType.Keyword)
        @ApiModelProperty("运单ID")
        private Long waybillId;

        @ApiModelProperty("订单合同号")
        @Field(type = FieldType.Keyword)
        private String contractNo;

        @ApiModelProperty("发货方名称")
        @Field(type = FieldType.Keyword)
        private String customerName;

        @ApiModelProperty("收货方名称")
        @Field(type = FieldType.Keyword)
        private String consigneeName;

        @ApiModelProperty("收货联系人")
        @Field(type = FieldType.Keyword)
        private String toContactName;

    }

    @Id
    @ApiModelProperty("唯一主键(租户+合单ID)")
    @Field(type = FieldType.Keyword)
    private String id;

    @Field(type = FieldType.Long)
    @ApiModelProperty("合单ID")
    private Long combineId;

    @ApiModelProperty("合单编号")
    @Field(type = FieldType.Keyword)
    private String no;

    @ApiModelProperty("合单同号")
    @Field(type = FieldType.Keyword)
    private String contractNo;

    @ApiModelProperty("承运方名称")
    @Field(type = FieldType.Keyword)
    private String carrierName;

    @ApiModelProperty("承运方联系人")
    @Field(type = FieldType.Keyword)
    private String carrierContactName;

    @ApiModelProperty("承运方联系电话")
    @Field(type = FieldType.Keyword)
    private String carrierContactMobile;

    @ApiModelProperty("总单数(运单)")
    @Field(type = FieldType.Integer)
    private Integer totalWaybillQuantity;

    @ApiModelProperty("总数量(物品)")
    @Field(type = FieldType.Integer)
    private Integer totalQuantity;

    @ApiModelProperty("总重量(含补差)")
    @Field(type = FieldType.Double)
    private BigDecimal calculateWeight;

    @ApiModelProperty("总体积(含补差)")
    @Field(type = FieldType.Double)
    private BigDecimal calculateVolume;

    @ApiModelProperty("总价值(含补差)")
    @Field(type = FieldType.Double)
    private BigDecimal calculateValue;

//    @ApiModelProperty("发货方名称(去重)")
//    @Field(type = FieldType.Keyword)
//    private List<String> distinctCustomerName;
//
//    @ApiModelProperty("发货地址(去重)")
//    @Field(type = FieldType.Keyword)
//    private List<String> distinctFromAddress;
//
//    @ApiModelProperty("收货方名称(去重)")
//    @Field(type = FieldType.Keyword)
//    private List<String> distinctConsigneeName;
//
//    @ApiModelProperty("收货方地址(去重)")
//    @Field(type = FieldType.Keyword)
//    private List<String> distinctToAddress;

    @ApiModelProperty("合单状态")
    @Field(type = FieldType.Integer)
    private Integer status;

    @ApiModelProperty("设备类型 0未绑定， 1 电子回单  2快递")
    @Field(type = FieldType.Integer)
    private Integer trackType;

    @ApiModelProperty("设备编号/快递号")
    @Field(type = FieldType.Keyword)
    private String deviceCode;

    @ApiModelProperty("发货开始时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime fromTime;

    @ApiModelProperty("发货结束时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime toTime;

    @ApiModelProperty("创建时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime createAt;

    @ApiModelProperty("租户ID)")
    @Field(type = FieldType.Long)
    private Long tenantId;

    @ApiModelProperty("运单列表")
    @Field(type = FieldType.Nested)
    List<Waybill> waybills;

    @ApiModelProperty("运单数量")
    @Field(type = FieldType.Integer)
    private Integer waybillSize;

    @ApiModelProperty("关单状态 10撤回中, 20待审核, 30拒绝中,40拒绝,50关单中，60同意")
    @Field(type = FieldType.Integer)
    private Integer closeStatus;

    @ApiModelProperty("报价状态")
    @Field(type = FieldType.Integer)
    private Integer quotationStatus;

    @ApiModelProperty("已产生费用 0否，1是")
    @Field(type = FieldType.Integer)
    private Integer feeGenerated;

    @ApiModelProperty("总费用")
    @Field(type = FieldType.Double)
    private BigDecimal totalFee;

    @ApiModelProperty("类型：10发货方合单，20：承运方合单")
    @Field(type = FieldType.Integer)
    private Integer waybillType;

    @ApiModelProperty("自营司机")
    @Field(type = FieldType.Keyword)
    private String driverName;
}
